<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
  
  <head>
    
    <%@ include file="/WEB-INF/include/meta.jsp"%>
    <%@ include file="/WEB-INF/include/css.jsp"%>
    
  </head>
  <!-- end header -->
  <body>
    <div class="page-group">
      <div class="page page-current">
        
        <header class="bar bar-nav fs-header-small">
          <a href="${ctx.host}/profile/courses" class="icon icon-left pull-left"></a>
          <h1 class="title">我的课程</h1>
          <c:if test="${not empty courseRound.schedules}">
            <a href="#" class="icon pull-right open-rules"><i class="icon icon-help"></i></a>
          </c:if>
        </header>
        
        <div class="content">
          
          <div class="list-block media-list no-margin">
            <ul>
              <li class="course" style="height:7.5rem;">
                <div class="item-content">
                  <div class="item-media"><img src="${cloud.prod}/${courseRound.course.cover}-avatar" style='width: 4rem;'></div>
                  <div class="item-inner" style="height:6.5rem;">
                    <div class="item-title-row">
                      <div class="item-title">${courseRound.course.name}</div>
                    </div>
                    <div class="item-text" style="height:3.1rem; overflow: initial;-webkit-line-clamp: 5;">
                      <c:if test="${courseRound.coach == null}">
                        暂未给您分配教练，请耐心等待~<br>
                      </c:if>
                      <c:if test="${courseRound.coach != null}">
                         主教练：${courseRound.coach.name}<br>
                       </c:if>
                      <c:if test="${courseRound.courseStatus.ready || courseRound.courseStatus.hold}">
                        课程开始时间:<fmt:formatDate value="${courseRound.effectiveStart}" pattern="yyyy-MM-dd"/><br>
                      <c:if test="${courseRound.effectiveEndDays != -1}">
                      <span style="color: red;">有效期：剩余${courseRound.effectiveEndDays}天(至<fmt:formatDate value="${courseRound.effectiveEndTime}" pattern="yyyy-MM-dd"/>)<br /></span>
                      </c:if>
                      </c:if>
                      <c:if test="${courseRound.courseStatus.prepare}">
                        您还未排课，点击按钮进行排课哦~<br>
                      </c:if>
                      已完成&nbsp;<span class="color-dark">${courseRound.finished}</span>&nbsp;课时。
                    </div>
                  </div>
                </div>
              </li>
            </ul>
          </div>
          
          <c:choose>
            <c:when test="${courseRound.coach == null}">
              <div style="text-align: center; margin-top: 100px;">
                <img alt="" src="${ctx.resource}/image/hold.png" style="width: 100px;">
                <p class="color-gray no-margin" style="color: #A9B7B7;">分配教练中</p>
              </div>
            </c:when>
            <c:when test="${courseRound.courseStatus.hold}">
              <div style="text-align: center;">
                <img alt="" src="${ctx.resource}/image/hold.png" style="width: 100px;">
                <p class="color-gray no-margin" style="color: #A9B7B7;">课程已冻结</p>
              </div>
            </c:when>
            <c:when test="${courseRound.courseStatus.finish}">
              <div style="text-align: center;">
                <img alt="" src="${ctx.resource}/image/hold.png" style="width: 100px;">
                <p class="color-gray no-margin" style="color: #A9B7B7;">课程已完成</p>
              </div>
            </c:when>
            <c:when test="${courseRound.courseStatus.expire}">
              <div style="text-align: center;">
                <img alt="" src="${ctx.resource}/image/hold.png" style="width: 100px;">
                <p class="color-gray no-margin" style="color: #A9B7B7;">课程已逾期，请联系教练</p>
              </div>
            </c:when>
            <c:when test="${courseRound.courseStatus.cancel}">
              <div style="text-align: center;">
                <img alt="" src="${ctx.resource}/image/hold.png" style="width: 100px;">
                <p class="color-gray no-margin" style="color: #A9B7B7;">课程已取消</p>
              </div>
            </c:when>
            <c:when test="${courseRound.courseStatus.activate}">
              <div style="text-align: center;">
                <img alt="" src="${ctx.resource}/image/hold.png" style="width: 100px;">
                <p class="color-gray no-margin" style="color: #A9B7B7;">课程待激活，请联系店长</p>
              </div>
            </c:when>
            <c:otherwise>
              <p style="padding:0 1.8rem;">
	              <c:choose>
	                <c:when test="${needTarget}">
	                  <a href="javascript:void(0);" data-redirect="${ctx.host}/profile/courses/${courseRound.id}/appointment?site=${courseRound.site.id}&appoint=true" class="button button-big button-fill ft-button-dark confirm-target">预约课程</a>
	                </c:when>
	                <c:otherwise>
		                <a href="${ctx.host}/profile/courses/${courseRound.id}/appointment?site=${courseRound.site.id}&appoint=true" class="button button-big button-fill ft-button-dark">预约课程</a>
	                </c:otherwise>
	              </c:choose>
              </p>
              
               <c:if test="${ empty courseRound.schedules}">
                <div style="padding: 0 2rem; margin-bottom: 1.5rem;">
                  <h4 class="text-center" style="color: #777; margin-bottom: .5rem;">约课须知</h4>
                  <p style="margin: 0px; font-size: .7rem; color: #999;">1：普通用户每日只能预约一次课程。</p>
                  <p style="margin: 0px; font-size: .7rem; color: #999;">2：普通用户超过两次课程逾期（未签到或未去上课）将变为失信用户。</p>
                  <p style="margin: 0px; font-size: .7rem; color: #999;">3：失信用户每周只能预约一节课程。</p>
                  <p style="margin: 0px; font-size: .7rem; color: #999;">4：失信用户最近连续签到两天后，将变回普通用户。</p>
                 </div>
               </c:if>
            </c:otherwise>
          </c:choose>
          <c:if test="${not empty courseRound.coach}">
                 <div class="row course-grid">
                  <div class="col-33">
                    <a href="${ctx.host}/profile/courses/${courseRound.id}/schedules">
                      <i class="icon icon-grid-schedule"></i><br>
                      课程记录
                    </a>
                  </div>
                  <c:if test="${not empty courseRound.fitnessGroup}">
                    <div class="col-33">
                    <a href="${ctx.host}/profile/courses/${courseRound.id}/weekly-coursewares">
                      <i class="icon icon-grid-week"></i><br>
                      家庭作业
                    </a>
                  </div>
                  <div class="col-33">
                    <a href="${ctx.host}/profile/courses/${courseRound.id}/round-coursewares">
                      <i class="icon icon-grid-courseware"></i><br>
                      上课课件
                    </a>
                  </div>
                  </c:if>
                  <div class="col-33">
                    <a href="${ctx.host}/profile/courses/${courseRound.id}/inbody-records">
                      <i class="icon icon-grid-inbody"></i><br>
                      体测记录
                    </a>
                  </div>
                  <div class="col-33">
                    <a href="${ctx.host}/profile/courses/${courseRound.id}/bmr-records">
                      <i class="icon icon-grid-bmr"></i><br>
                      三围记录
                    </a>
                  </div>
                  <div class="col-33">
                      <a href="${ctx.host}/profile/courses/${courseRound.id}/targets">
                        <i class="icon icon-grid-target"></i><br>
                        学员目标
                      </a>  
                    </div>
                </div>
              </c:if>
        </div>
        <!-- End Content -->
        
      </div>
    </div>
    
    <%@ include file="/WEB-INF/include/script.jsp"%>
    <d:resource type="script" root="${ctx.resource}/build" src="js/page/course/course-detail.js" />
    <script type="text/javascript">
      require(['page/course/course-detail'], function(page) {
        page.init({
          'roundId': ${courseRound.id}
        });
      })
    </script>
    
  </body>
</html>